package com.student.controller;

import com.student.service.HealthInfoService;
import com.student.utils.AjaxResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
public class HealthInfoController {
    @Resource
    private HealthInfoService healthInfoService;
    /**
     * 健康信息录入
     * @param time
     * @param height
     * @param weight
     * @param diet
     * @param BP
     * @param SQ
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/healthInfo_Add")
    public AjaxResult healthInfoAdd(@RequestParam(value = "time") String time,
                                    @RequestParam(value = "height") Float height,
                                    @RequestParam(value = "weight") Float weight,
                                    @RequestParam(value = "diet") String diet,
                                    @RequestParam(value = "BP") Float BP,
                                    @RequestParam(value = "SQ") String SQ){
        return healthInfoService.insertHealthInfo(time, height, weight, diet, BP, SQ);

    }

    @ResponseBody
    @RequestMapping(value = "/selectHealthInfo")
    public AjaxResult selectHealthInfo(@RequestParam(value = "month") String month){
        System.out.println("qingqiushuju: "+month);
        return healthInfoService.selectHealthInfo(month);
    }

    //修改
    @ResponseBody
    @RequestMapping(value = "/modify_info")
    public AjaxResult modify_info(@RequestParam(value = "time") String time,
                                  @RequestParam(value = "height") Float height,
                                  @RequestParam(value = "weight") Float weight,
                                  @RequestParam(value = "diet") String diet,
                                  @RequestParam(value = "BP") Float BP,
                                  @RequestParam(value = "SQ") String SQ){
        return null;
    }
    //删除
    @ResponseBody
    @RequestMapping(value = "/delete_info")
    public AjaxResult delete_info(@RequestParam(value = "healthInfo_id") int healthInfo_id){
        return null;
    }
    //查
    @ResponseBody
    @RequestMapping(value = "/seleHealth_info")
    public AjaxResult seleHealth_info(HttpSession session){
       Integer health_id = (Integer) session.getAttribute("health_id");
       return healthInfoService.selectInfo(health_id);
    }
}
